function rmCloud (image) {
    var cloudShadowBitMask = ( 1<< 3);
    var cloudsBitMask = (1 << 5);
    var qa = image.select('pixel_qa');
    var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
        .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
    
    return image.updateMask(mask);
}


// add NDVI band to landsat 8 image
// B5 is the near infrared
// B4 is the red
function addNDVItoL8 (image) {
    var ndvi = normalizedDifference(["B5","B4"]);
    return image.addBands(ndvi.rename("NDVI"));
}